package com.ruoyi.hospital.controller.operation;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.operation.OperationAdvisoryPrice;
import com.ruoyi.hospital.service.operation.IOperationAdvisoryPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 咨询价格管理Controller
 * 
 * @author wendao
 * @date 2024-09-13
 */
@RestController
@RequestMapping("/hospital/advisoryPrice")
public class OperationAdvisoryPriceController extends BaseController
{
    @Autowired
    private IOperationAdvisoryPriceService operationAdvisoryPriceService;

    /**
     * 查询咨询价格管理列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperationAdvisoryPrice operationAdvisoryPrice)
    {
        startPage();
        List<OperationAdvisoryPrice> list = operationAdvisoryPriceService.selectOperationAdvisoryPriceList(operationAdvisoryPrice);
        return getDataTable(list);
    }

    /**
     * 导出咨询价格管理列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:export')")
    @Log(title = "咨询价格管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationAdvisoryPrice operationAdvisoryPrice)
    {
        List<OperationAdvisoryPrice> list = operationAdvisoryPriceService.selectOperationAdvisoryPriceList(operationAdvisoryPrice);
        ExcelUtil<OperationAdvisoryPrice> util = new ExcelUtil<OperationAdvisoryPrice>(OperationAdvisoryPrice.class);
        util.exportExcel(response, list, "咨询价格管理数据");
    }

    /**
     * 获取咨询价格管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(operationAdvisoryPriceService.selectOperationAdvisoryPriceById(id));
    }

    /**
     * 新增咨询价格管理
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:add')")
    @Log(title = "咨询价格管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperationAdvisoryPrice operationAdvisoryPrice)
    {
        return toAjax(operationAdvisoryPriceService.insertOperationAdvisoryPrice(operationAdvisoryPrice));
    }

    /**
     * 修改咨询价格管理
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:edit')")
    @Log(title = "咨询价格管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperationAdvisoryPrice operationAdvisoryPrice)
    {
        return toAjax(operationAdvisoryPriceService.updateOperationAdvisoryPrice(operationAdvisoryPrice));
    }

    /**
     * 删除咨询价格管理
     */
    @PreAuthorize("@ss.hasPermi('hospital:advisoryPrice:remove')")
    @Log(title = "咨询价格管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(operationAdvisoryPriceService.deleteOperationAdvisoryPriceByIds(ids));
    }
}
